IAEA
set.seed(7712) # for reproduction
# global chunk options
library(knitr)
opts_chunk$set(cache=TRUE, autodep=TRUE, out.width = "\\textwidth", fig.height = 6, fig.width = 8, dpi = 300, warning=F, echo=T, dev = "png", fig.pos = "tbh")
data <- read.csv("../data/raw-data.csv")
terms2 <- read.csv("../data/iaea-participation-events.csv")
library(grid)
library(ggplot2)
library(reshape2)
library(dplyr)
# for some nice fonts
library(extrafont)
#font_import() # run the first time on a system, #fonts() to list available fonts
loadfonts()
## use colour scheme: http://www.colourlovers.com/palette/1419154/CENSORED.
#ggplot(filter(data, IO == "IAEA")) + geom_bar(aes(x = Year, y = TALK.Part), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("References to Participation") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12))
data$decade <- NA
data$decade[which(data$Year < 1961)] <- "1950s"
data$decade[which(data$Year > 1960 & data$Year < 1971)] <- "1960s"
data$decade[which(data$Year > 1970 & data$Year < 1981)] <- "1970s"
data$decade[which(data$Year > 1980 & data$Year < 1991)] <- "1980s"
data$decade[which(data$Year > 1990 & data$Year < 2001)] <- "1990s"
data$decade[which(data$Year > 2000 & data$Year < 2011)] <- "2000s"
ggplot(filter(data, IO == "IAEA", decade != "NA")) + geom_bar(aes(x = decade, y = TALK.Part ), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("References to Participation") + xlab("Decade") + theme(text=element_text(family="Charis SIL", size=12)) + scale_y_continuous(breaks = seq(0, 25, 5))

plotframe <- data %>% filter(IO == "IAEA") %>% select(Year, ACT.Part.1, ACT.Part.3, ACT.Part.2)
plotframe <- melt(plotframe, id.vars = "Year")
ggplot() + geom_bar(data = filter(plotframe, variable == "ACT.Part.1"), aes(x = Year, y = value, fill = variable), stat="identity") + geom_line(data = filter(plotframe,variable != "ACT.Part.1"), aes(x = Year, y = value, linetype = variable), size = 1) + theme_bw() + theme(legend.position = "right", legend.key.size = unit(0.5, "cm"), legend.key = element_blank()) + ylab("No.") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + scale_fill_manual(name = "", values = "#BDBDBD", label = "NGOs at GC") + scale_linetype_manual(name = "", values = c(1, 3), labels = c("New NGOs at GC", "NGO representatives"))

p <- melt(select(terms2, GROUP_SCIENCE, GROUP_TRAINING, GROUP_ADVICE, Year), id = "Year")
ggplot(filter(data, IO == "IAEA")) + geom_bar(data = p, aes(x = Year, y = value, fill = variable), stat = "identity", position = "stack") + geom_line(aes(x = Year, y = ACT.Part.4), fill="#BDBDBD", color="black", size=1) + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Participation Events in IAEA Annual Reports") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) +scale_fill_grey()

ggplot(filter(data, IO == "IAEA", decade != "NA")) + geom_bar(aes(x = decade, y = TALK.Trans), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("References to Transparency") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12))

ggplot(filter(data, IO == "IAEA")) + geom_bar(aes(x = Year, y = ACT.Trans.1), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Share of IAEA Public Information Budget") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(ylim = c(0.01, 0.08))

ggplot(filter(data, IO == "IAEA")) + geom_bar(aes(x = Year, y = RB.Budget.All/1000000), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("IAEA Budget in Million 2009 USD") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12))

iaea_budget <- read.csv2("../data/IAEA-BUDGET.csv")
iaea_budget2 <- data.frame(Year = iaea_budget$Year, Staff = iaea_budget$Staff.Costs/iaea_budget$Total.Budget, Verification = iaea_budget$Verification/iaea_budget$Total.Budget, Assistance = (iaea_budget$TA + iaea_budget$Fund)/iaea_budget$Total.Budget)
m <- melt(iaea_budget2, id.vars = "Year")
ggplot(m, aes(x = Year, fill = variable, y = value)) + geom_bar(stat= "identity", position = "dodge") + scale_fill_manual(values = c("#BDBDBD", "#353334", "#7E7C7D"), name = "") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("as share of total budget") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(xlim = c(1957, 2011))

ggplot(filter(data, IO == "IAEA")) + geom_bar(aes(x = Year, y = RB.Inequality), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Gini Coefficient of Membership GDP") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(ylim = c(0.7, 0.85))

#ggplot(filter(data, IO == "IAEA")) + geom_bar(aes(x = Year, y = NB.visibility.1), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Hits in the Lexis Nexis Global News Corpus") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + geom_line(aes(x = Year, y = NB.visibility.2), size = 1)
copy <- data
names(copy)[names(copy)=="NB.visibility.1"] <- "Total.Visibility"
names(copy)[names(copy)=="NB.visibility.2"] <- "Headlines"
p <- melt(select(filter(copy, IO == "IAEA"), Year, Total.Visibility, Headlines), id = "Year")
ggplot(data = p, aes(x = Year, y = value)) + geom_line(size = 1, color="#7E7C7D") + facet_grid(variable ~ ., scale = "free") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Hits in the Lexis Nexis Global News Corpus") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(xlim = c(1970, 2012))

ggplot(filter(data, IO == "IAEA")) + geom_bar(aes(x = Year, y = NB.dem.mem), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Share of Democracies in IAEA Membership") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(ylim = c(0.2, 0.6))

ggplot(filter(data, IO == "IAEA")) + geom_bar(aes(x = Year, y = NB.og.norm), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Presence of Open Governance Norm, in 10 Mio * Hits in Google Books Corpus") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12))

OPCW
set.seed(7712) # for reproduction
# global chunk options
data <- read.csv("../data/raw-data.csv")
terms3 <- read.csv("../data/opcw-participation-events.csv")
data$decade <- NA
data$decade[which(data$Year > 1990 & data$Year < 2001)] <- "1990s"
data$decade[which(data$Year > 2000 & data$Year < 2011)] <- "2000s"
data$fiveyears <- c(rep(NA, 55), rep("1997-2001", 5), rep("2002-2006", 5), rep("2007-2011", 5))
ggplot(filter(data, IO == "OPCW")) + geom_bar(aes(x = fiveyears, y = TALK.Part), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("References to Participation") + xlab("5-year period") + theme(text=element_text(family="Charis SIL", size=12))

#
plotframe <- data %>% filter(IO == "OPCW") %>% select(Year, ACT.Part.1, ACT.Part.3, ACT.Part.2)
plotframe <- melt(plotframe, id.vars = "Year")
ggplot() + geom_bar(data = filter(plotframe, variable == "ACT.Part.1"), aes(x = Year, y = value, fill = variable), stat="identity") + geom_line(data = filter(plotframe,variable != "ACT.Part.1"), aes(x = Year, y = value, linetype = variable), size = 1) + theme_bw() + theme(legend.position = "right", legend.key.size = unit(0.5, "cm"), legend.key = element_blank()) + ylab("No.") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + scale_fill_manual(name = "", values = "#BDBDBD", label = "NGOs at CSP") + scale_linetype_manual(name = "", values = c(1, 3), labels = c("New NGOs at CSP", "NGO representatives"))

p <- melt(select(terms3, GROUP_SCIENCE, GROUP_TRAINING, GROUP_ADVICE, Year), id = "Year")
ggplot(filter(data, IO == "OPCW")) + geom_bar(data = p, aes(x = Year, y = value, fill = variable), stat = "identity", position = "stack") + geom_line(aes(x = Year, y = ACT.Part.4), fill="#BDBDBD", color="black", size=1) + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Participation Events in OPCW Annual Reports") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) +scale_fill_grey()

ggplot(filter(data, IO == "OPCW")) + geom_bar(aes(x = fiveyears, y = TALK.Trans), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("References to Participation") + xlab("5-year period") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(ylim = c(0, 10))

ggplot(filter(data, IO == "OPCW")) + geom_bar(aes(x = Year, y = ACT.Trans.1), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Share of IAEA Public Information Budget") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(ylim = c(0.01, 0.08))

ggplot(filter(data, IO == "OPCW")) + geom_bar(aes(x = Year, y = RB.Budget.All/1000000), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("OPCW Budget in Million 2009 USD") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(ylim = c(40, 120))

opcw_budget <- read.csv2("../data/OPCW-BUDGET.csv")
opcw_budget2 <- data.frame(Year = opcw_budget$Year, Staff = opcw_budget$Staff.Costs/opcw_budget$Total.Budget, Verification = opcw_budget$Verification/opcw_budget$Total.Budget, Cooperation = (opcw_budget$Cooperation + opcw_budget$Fund)/opcw_budget$Total.Budget)
m <- melt(opcw_budget2, id.vars = "Year", measure.vars = c("Staff", "Verification", "Cooperation"))
ggplot(m, aes(x = Year, fill = variable, y = value)) + geom_bar(stat= "identity", position = "dodge") + scale_fill_manual(values = c("#BDBDBD", "#353334", "#7E7C7D"), name = "") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("as share of total budget") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12))

ggplot(filter(data, IO == "OPCW")) + geom_bar(aes(x = Year, y = RB.Inequality), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Gini Coefficient of Membership GDP") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(ylim = c(0.7, 0.85))

copy <- data
names(copy)[names(copy)=="NB.visibility.1"] <- "Total.Visibility"
names(copy)[names(copy)=="NB.visibility.2"] <- "Headlines"
p <- melt(select(filter(copy, IO == "OPCW"), Year, Total.Visibility, Headlines), id = "Year")
ggplot(data = p, aes(x = Year, y = value)) + geom_line(size = 1, color="#7E7C7D") + facet_grid(variable ~ ., scale = "free") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Hits in the Lexis Nexis Global News Corpus") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(xlim = c(1997, 2012))

ggplot(filter(data, IO == "OPCW")) + geom_bar(aes(x = Year, y = NB.dem.mem), fill="#BDBDBD", color="#7E7C7D", stat="identity") + theme_bw() + theme(legend.position = "bottom", legend.key.size = unit(1.5, "cm"), legend.key = element_blank()) + ylab("Share of Democracies in OPCW Membership") + xlab("Year") + theme(text=element_text(family="Charis SIL", size=12)) + coord_cartesian(ylim = c(0.2, 0.6))
